{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1001\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "        toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1001\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) {\n",
       "        if (callback != null)\n",
       "          callback();\n",
       "      });\n",
       "    } finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.debug(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(css_urls, js_urls, callback) {\n",
       "    if (css_urls == null) css_urls = [];\n",
       "    if (js_urls == null) js_urls = [];\n",
       "\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
       "\n",
       "    function on_load() {\n",
       "      root._bokeh_is_loading--;\n",
       "      if (root._bokeh_is_loading === 0) {\n",
       "        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
       "        run_callbacks()\n",
       "      }\n",
       "    }\n",
       "\n",
       "    function on_error() {\n",
       "      console.error(\"failed to load \" + url);\n",
       "    }\n",
       "\n",
       "    for (var i = 0; i < css_urls.length; i++) {\n",
       "      var url = css_urls[i];\n",
       "      const element = document.createElement(\"link\");\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.rel = \"stylesheet\";\n",
       "      element.type = \"text/css\";\n",
       "      element.href = url;\n",
       "      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
       "      document.body.appendChild(element);\n",
       "    }\n",
       "\n",
       "    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
       "\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var element = document.createElement('script');\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.async = false;\n",
       "      element.src = url;\n",
       "      if (url in hashes) {\n",
       "        element.crossOrigin = \"anonymous\";\n",
       "        element.integrity = \"sha384-\" + hashes[url];\n",
       "      }\n",
       "      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.head.appendChild(element);\n",
       "    }\n",
       "  };\n",
       "\n",
       "  function inject_raw_css(css) {\n",
       "    const element = document.createElement(\"style\");\n",
       "    element.appendChild(document.createTextNode(css));\n",
       "    document.body.appendChild(element);\n",
       "  }\n",
       "\n",
       "  \n",
       "  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
       "  var css_urls = [];\n",
       "  \n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "    \n",
       "    \n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if (root.Bokeh !== undefined || force === true) {\n",
       "      \n",
       "    for (var i = 0; i < inline_js.length; i++) {\n",
       "      inline_js[i].call(root, root.Bokeh);\n",
       "    }\n",
       "    if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(css_urls, js_urls, function() {\n",
       "      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1001\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) {\n        if (callback != null)\n          callback();\n      });\n    } finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.debug(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(css_urls, js_urls, callback) {\n    if (css_urls == null) css_urls = [];\n    if (js_urls == null) js_urls = [];\n\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n    function on_load() {\n      root._bokeh_is_loading--;\n      if (root._bokeh_is_loading === 0) {\n        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n        run_callbacks()\n      }\n    }\n\n    function on_error() {\n      console.error(\"failed to load \" + url);\n    }\n\n    for (var i = 0; i < css_urls.length; i++) {\n      var url = css_urls[i];\n      const element = document.createElement(\"link\");\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.rel = \"stylesheet\";\n      element.type = \"text/css\";\n      element.href = url;\n      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n      document.body.appendChild(element);\n    }\n\n    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var element = document.createElement('script');\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.async = false;\n      element.src = url;\n      if (url in hashes) {\n        element.crossOrigin = \"anonymous\";\n        element.integrity = \"sha384-\" + hashes[url];\n      }\n      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.head.appendChild(element);\n    }\n  };\n\n  function inject_raw_css(css) {\n    const element = document.createElement(\"style\");\n    element.appendChild(document.createTextNode(css));\n    document.body.appendChild(element);\n  }\n\n  \n  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n  var css_urls = [];\n  \n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    function(Bokeh) {\n    \n    \n    }\n  ];\n\n  function run_inline_js() {\n    \n    if (root.Bokeh !== undefined || force === true) {\n      \n    for (var i = 0; i < inline_js.length; i++) {\n      inline_js[i].call(root, root.Bokeh);\n    }\n    if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(css_urls, js_urls, function() {\n      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import figure,output_notebook,show\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 折线图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"0c6dcd67-a188-4446-941b-45cd4952252e\" data-root-id=\"1002\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"c4f5288f-a686-40b9-bac2-3a0c91085512\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1013\"}],\"center\":[{\"id\":\"1016\"},{\"id\":\"1020\"},{\"id\":\"1048\"}],\"left\":[{\"id\":\"1017\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"1038\"}],\"title\":{\"id\":\"1003\"},\"toolbar\":{\"id\":\"1028\"},\"x_range\":{\"id\":\"1005\"},\"x_scale\":{\"id\":\"1009\"},\"y_range\":{\"id\":\"1007\"},\"y_scale\":{\"id\":\"1011\"}},\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1035\"}},\"id\":\"1039\",\"type\":\"CDSView\"},{\"attributes\":{\"overlay\":{\"id\":\"1027\"}},\"id\":\"1023\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1036\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1014\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1021\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1021\"},{\"id\":\"1022\"},{\"id\":\"1023\"},{\"id\":\"1024\"},{\"id\":\"1025\"},{\"id\":\"1026\"}]},\"id\":\"1028\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1024\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1025\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1018\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data\":{\"x\":[1,2,3,4,5,7,9],\"y\":[6,7,8,9,5,4,5]},\"selected\":{\"id\":\"1047\"},\"selection_policy\":{\"id\":\"1046\"}},\"id\":\"1035\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1013\"},\"ticker\":null},\"id\":\"1016\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1009\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1027\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1026\",\"type\":\"HelpTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1035\"},\"glyph\":{\"id\":\"1036\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1037\"},\"selection_glyph\":null,\"view\":{\"id\":\"1039\"}},\"id\":\"1038\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis\":{\"id\":\"1017\"},\"dimension\":1,\"ticker\":null},\"id\":\"1020\",\"type\":\"Grid\"},{\"attributes\":{\"axis_label\":\"x\\u8f74\",\"formatter\":{\"id\":\"1043\"},\"ticker\":{\"id\":\"1014\"}},\"id\":\"1013\",\"type\":\"LinearAxis\"},{\"attributes\":{\"text\":\"line example\"},\"id\":\"1003\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1005\",\"type\":\"DataRange1d\"},{\"attributes\":{\"axis_label\":\"y\\u8f74\",\"formatter\":{\"id\":\"1041\"},\"ticker\":{\"id\":\"1018\"}},\"id\":\"1017\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1007\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1011\",\"type\":\"LinearScale\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":2,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1037\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1043\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"items\":[{\"id\":\"1049\"}]},\"id\":\"1048\",\"type\":\"Legend\"},{\"attributes\":{},\"id\":\"1041\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1046\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"label\":{\"value\":\"Temp\"},\"renderers\":[{\"id\":\"1038\"}]},\"id\":\"1049\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1047\",\"type\":\"Selection\"}],\"root_ids\":[\"1002\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"c4f5288f-a686-40b9-bac2-3a0c91085512\",\"root_ids\":[\"1002\"],\"roots\":{\"1002\":\"0c6dcd67-a188-4446-941b-45cd4952252e\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1002"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=[1,2,3,4,5,7,9]\n",
    "y=[6,7,8,9,5,4,5]\n",
    "p=figure(title='line example',\n",
    "         x_axis_label='x轴',\n",
    "         y_axis_label='y轴',# x\\y轴命名\n",
    "         width=300,\n",
    "         height=300)\n",
    "\n",
    "\n",
    "p.line(x,y,legend='Temp',line_width=2)\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 多段折线图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"162b5ba9-4ab1-4ec1-85b8-1a1449e11489\" data-root-id=\"1106\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"206103e3-7f98-4bdf-85fd-4b8050fa1498\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1117\"}],\"center\":[{\"id\":\"1120\"},{\"id\":\"1124\"}],\"left\":[{\"id\":\"1121\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"1142\"}],\"title\":{\"id\":\"1107\"},\"toolbar\":{\"id\":\"1132\"},\"x_range\":{\"id\":\"1109\"},\"x_scale\":{\"id\":\"1113\"},\"y_range\":{\"id\":\"1111\"},\"y_scale\":{\"id\":\"1115\"}},\"id\":\"1106\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1118\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1158\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1159\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1125\",\"type\":\"PanTool\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"field\":\"line_color\"},\"xs\":{\"field\":\"xs\"},\"ys\":{\"field\":\"ys\"}},\"id\":\"1141\",\"type\":\"MultiLine\"},{\"attributes\":{\"text\":\"multi_line\"},\"id\":\"1107\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1153\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis\":{\"id\":\"1117\"},\"ticker\":null},\"id\":\"1120\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1109\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1111\",\"type\":\"DataRange1d\"},{\"attributes\":{\"formatter\":{\"id\":\"1153\"},\"ticker\":{\"id\":\"1122\"}},\"id\":\"1121\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1122\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1121\"},\"dimension\":1,\"ticker\":null},\"id\":\"1124\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1155\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data\":{\"line_alpha\":[0.4,0.8],\"line_color\":[\"firbrick\",\"navy\"],\"xs\":[[2,4,6,7,9],[3,6,7,8,10,11,12]],\"ys\":[[3,5,4,8,7],[6,5,4,8,9,15,16]]},\"selected\":{\"id\":\"1159\"},\"selection_policy\":{\"id\":\"1158\"}},\"id\":\"1139\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1115\",\"type\":\"LinearScale\"},{\"attributes\":{\"source\":{\"id\":\"1139\"}},\"id\":\"1143\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1113\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1131\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"line_alpha\":{\"field\":\"line_alpha\"},\"line_color\":{\"field\":\"line_color\"},\"xs\":{\"field\":\"xs\"},\"ys\":{\"field\":\"ys\"}},\"id\":\"1140\",\"type\":\"MultiLine\"},{\"attributes\":{},\"id\":\"1126\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"1155\"},\"ticker\":{\"id\":\"1118\"}},\"id\":\"1117\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1130\",\"type\":\"HelpTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1131\"}},\"id\":\"1127\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1128\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1129\",\"type\":\"ResetTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1125\"},{\"id\":\"1126\"},{\"id\":\"1127\"},{\"id\":\"1128\"},{\"id\":\"1129\"},{\"id\":\"1130\"}]},\"id\":\"1132\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"1139\"},\"glyph\":{\"id\":\"1140\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1141\"},\"selection_glyph\":null,\"view\":{\"id\":\"1143\"}},\"id\":\"1142\",\"type\":\"GlyphRenderer\"}],\"root_ids\":[\"1106\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"206103e3-7f98-4bdf-85fd-4b8050fa1498\",\"root_ids\":[\"1106\"],\"roots\":{\"1106\":\"162b5ba9-4ab1-4ec1-85b8-1a1449e11489\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1106"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=[[2,4,6,7,9],[3,6,7,8,10,11,12]]\n",
    "y=[[3,5,4,8,7],[6,5,4,8,9,15,16]]\n",
    "\n",
    "p=figure(plot_width=300,plot_height=300,title='multi_line')\n",
    "p.multi_line(x,y,color=['firbrick','navy'],alpha=[0.4,0.8])\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 折线图实践"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 示例代码（数学模型）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"31dc48d4-d601-4c44-99ad-eed5dc5b80a9\" data-root-id=\"1208\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"9bdfbd1a-2cec-42fb-a669-2be2263164ba\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1219\"}],\"center\":[{\"id\":\"1222\"},{\"id\":\"1226\"},{\"id\":\"1250\"}],\"left\":[{\"id\":\"1223\"}],\"plot_height\":350,\"plot_width\":350,\"renderers\":[{\"id\":\"1240\"},{\"id\":\"1255\"},{\"id\":\"1270\"},{\"id\":\"1288\"},{\"id\":\"1308\"},{\"id\":\"1329\"}],\"title\":{\"id\":\"1209\"},\"toolbar\":{\"id\":\"1232\"},\"x_range\":{\"id\":\"1211\"},\"x_scale\":{\"id\":\"1215\"},\"y_range\":{\"id\":\"1213\"},\"y_scale\":{\"id\":\"1217\"}},\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1305\"}},\"id\":\"1309\",\"type\":\"CDSView\"},{\"attributes\":{\"num_minor_ticks\":10},\"id\":\"1224\",\"type\":\"LogTicker\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"white\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":3.0},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1254\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1220\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#888888\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1269\",\"type\":\"Line\"},{\"attributes\":{\"axis\":{\"id\":\"1219\"},\"ticker\":null},\"id\":\"1222\",\"type\":\"Grid\"},{\"attributes\":{\"source\":{\"id\":\"1252\"}},\"id\":\"1256\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"1267\"}},\"id\":\"1271\",\"type\":\"CDSView\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1227\"},{\"id\":\"1228\"},{\"id\":\"1229\"},{\"id\":\"1230\"}]},\"id\":\"1232\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1215\",\"type\":\"LinearScale\"},{\"attributes\":{\"line_color\":\"red\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1286\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1249\",\"type\":\"Selection\"},{\"attributes\":{\"label\":{\"value\":\"y=10^x\"},\"renderers\":[{\"id\":\"1288\"},{\"id\":\"1308\"}]},\"id\":\"1304\",\"type\":\"LegendItem\"},{\"attributes\":{\"data_source\":{\"id\":\"1326\"},\"glyph\":{\"id\":\"1327\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1328\"},\"selection_glyph\":null,\"view\":{\"id\":\"1330\"}},\"id\":\"1329\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1324\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data_source\":{\"id\":\"1267\"},\"glyph\":{\"id\":\"1268\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1269\"},\"selection_glyph\":null,\"view\":{\"id\":\"1271\"}},\"id\":\"1270\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"red\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1287\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1325\",\"type\":\"Selection\"},{\"attributes\":{\"fill_color\":{\"value\":\"white\"},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":3.0},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1253\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"1285\"}},\"id\":\"1289\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"y=x\"},\"renderers\":[{\"id\":\"1240\"},{\"id\":\"1255\"}]},\"id\":\"1251\",\"type\":\"LegendItem\"},{\"attributes\":{\"line_color\":\"#888888\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1268\",\"type\":\"Line\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1238\",\"type\":\"Line\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[1.2589254117941673,3.1622776601683795,10.0,31.622776601683793,100.0,316.22776601683796,1000.0]},\"selected\":{\"id\":\"1303\"},\"selection_policy\":{\"id\":\"1302\"}},\"id\":\"1285\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"ticker\":null},\"id\":\"1243\",\"type\":\"LogTickFormatter\"},{\"attributes\":{},\"id\":\"1248\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1245\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"click_policy\":\"hide\",\"items\":[{\"id\":\"1251\"},{\"id\":\"1284\"},{\"id\":\"1304\"},{\"id\":\"1349\"}],\"location\":\"top_left\"},\"id\":\"1250\",\"type\":\"Legend\"},{\"attributes\":{\"axis_label\":\"section\",\"formatter\":{\"id\":\"1245\"},\"ticker\":{\"id\":\"1220\"}},\"id\":\"1219\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data_source\":{\"id\":\"1237\"},\"glyph\":{\"id\":\"1238\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1239\"},\"selection_glyph\":null,\"view\":{\"id\":\"1241\"}},\"id\":\"1240\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1217\",\"type\":\"LogScale\"},{\"attributes\":{\"line_color\":\"orange\",\"line_dash\":[4,4],\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1327\",\"type\":\"Line\"},{\"attributes\":{\"fill_color\":{\"value\":\"white\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1306\",\"type\":\"Circle\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"white\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"red\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1307\",\"type\":\"Circle\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0]},\"selected\":{\"id\":\"1266\"},\"selection_policy\":{\"id\":\"1265\"}},\"id\":\"1252\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1231\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[1.2589254117941673,3.1622776601683795,10.0,31.622776601683793,100.0,316.22776601683796,1000.0]},\"selected\":{\"id\":\"1325\"},\"selection_policy\":{\"id\":\"1324\"}},\"id\":\"1305\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1266\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1302\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1326\"}},\"id\":\"1330\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1213\",\"type\":\"DataRange1d\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"orange\",\"line_dash\":[4,4],\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1328\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1303\",\"type\":\"Selection\"},{\"attributes\":{\"text\":\"log axis example\"},\"id\":\"1209\",\"type\":\"Title\"},{\"attributes\":{\"axis\":{\"id\":\"1223\"},\"dimension\":1,\"ticker\":null},\"id\":\"1226\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1211\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1282\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data_source\":{\"id\":\"1252\"},\"glyph\":{\"id\":\"1253\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1254\"},\"selection_glyph\":null,\"view\":{\"id\":\"1256\"}},\"id\":\"1255\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"y=10^(x^2)\"},\"renderers\":[{\"id\":\"1329\"}]},\"id\":\"1349\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1227\",\"type\":\"PanTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1239\",\"type\":\"Line\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[0.010000000000000002,0.25,1.0,2.25,4.0,6.25,9.0]},\"selected\":{\"id\":\"1283\"},\"selection_policy\":{\"id\":\"1282\"}},\"id\":\"1267\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"source\":{\"id\":\"1237\"}},\"id\":\"1241\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1265\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data_source\":{\"id\":\"1305\"},\"glyph\":{\"id\":\"1306\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1307\"},\"selection_glyph\":null,\"view\":{\"id\":\"1309\"}},\"id\":\"1308\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"y=x^2\"},\"renderers\":[{\"id\":\"1270\"}]},\"id\":\"1284\",\"type\":\"LegendItem\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0]},\"selected\":{\"id\":\"1249\"},\"selection_policy\":{\"id\":\"1248\"}},\"id\":\"1237\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data\":{\"x\":[0.1,0.5,1.0,1.5,2.0,2.5,3.0],\"y\":[1.023292992280754,1.7782794100389228,10.0,177.82794100389228,10000.0,1778279.410038923,1000000000.0]},\"selected\":{\"id\":\"1348\"},\"selection_policy\":{\"id\":\"1347\"}},\"id\":\"1326\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1283\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1230\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1347\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1348\",\"type\":\"Selection\"},{\"attributes\":{\"axis_label\":\"particles\",\"formatter\":{\"id\":\"1243\"},\"ticker\":{\"id\":\"1224\"}},\"id\":\"1223\",\"type\":\"LogAxis\"},{\"attributes\":{\"data_source\":{\"id\":\"1285\"},\"glyph\":{\"id\":\"1286\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1287\"},\"selection_glyph\":null,\"view\":{\"id\":\"1289\"}},\"id\":\"1288\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1229\",\"type\":\"ResetTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1231\"}},\"id\":\"1228\",\"type\":\"BoxZoomTool\"}],\"root_ids\":[\"1208\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"9bdfbd1a-2cec-42fb-a669-2be2263164ba\",\"root_ids\":[\"1208\"],\"roots\":{\"1208\":\"31dc48d4-d601-4c44-99ad-eed5dc5b80a9\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1208"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=[0.1,0.5,1.0,1.5,2.0,2.5,3.0]\n",
    "y0=[i**2 for i in x]\n",
    "y1=[10**i for i in x]\n",
    "y2=[10**(i**2) for i in x]\n",
    "\n",
    "p=figure(\n",
    "    tools='pan,box_zoom,reset,save',\n",
    "    y_axis_type='log',title='log axis example',\n",
    "    x_axis_label='section',y_axis_label='particles',\n",
    "    width=350,\n",
    "    height=350\n",
    ")\n",
    "p.line(x,x,legend='y=x')\n",
    "p.circle(x,x,legend='y=x',fill_color='white',size=3.0)\n",
    "p.line(x,y0,legend='y=x^2',line_color='#888888')\n",
    "p.line(x,y1,legend='y=10^x',line_color='red')\n",
    "p.circle(x,y1,legend='y=10^x',fill_color='white',color='red',size=4)\n",
    "p.line(x,y2,legend='y=10^(x^2)',line_color='orange',line_dash='4 4')\n",
    "p.legend.location='top_left'# 图例左右边\n",
    "p.legend.click_policy='hide' # 隐藏折现\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 示例代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.models import ColumnDataSource,NumeralTickFormatter,SingleIntervalTicker\n",
    "from bokeh.sampledata.us_marriages_divorces import data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Marriages</th>\n",
       "      <th>Divorces</th>\n",
       "      <th>Population</th>\n",
       "      <th>Marriages_per_1000</th>\n",
       "      <th>Divorces_per_1000</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1867</td>\n",
       "      <td>357000.0</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>36970000</td>\n",
       "      <td>9.7</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1868</td>\n",
       "      <td>345000.0</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>37885000</td>\n",
       "      <td>9.1</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1869</td>\n",
       "      <td>348000.0</td>\n",
       "      <td>11000.0</td>\n",
       "      <td>38870000</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1870</td>\n",
       "      <td>352000.0</td>\n",
       "      <td>11000.0</td>\n",
       "      <td>39905000</td>\n",
       "      <td>8.8</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1871</td>\n",
       "      <td>359000.0</td>\n",
       "      <td>12000.0</td>\n",
       "      <td>41010000</td>\n",
       "      <td>8.8</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>2007</td>\n",
       "      <td>2197000.0</td>\n",
       "      <td>856000.0</td>\n",
       "      <td>301696000</td>\n",
       "      <td>7.3</td>\n",
       "      <td>2.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>2008</td>\n",
       "      <td>2157000.0</td>\n",
       "      <td>844000.0</td>\n",
       "      <td>304543000</td>\n",
       "      <td>7.1</td>\n",
       "      <td>2.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>2009</td>\n",
       "      <td>2080000.0</td>\n",
       "      <td>840000.0</td>\n",
       "      <td>307240000</td>\n",
       "      <td>6.8</td>\n",
       "      <td>2.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>2010</td>\n",
       "      <td>2096000.0</td>\n",
       "      <td>872000.0</td>\n",
       "      <td>309776000</td>\n",
       "      <td>6.8</td>\n",
       "      <td>2.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>2011</td>\n",
       "      <td>2118000.0</td>\n",
       "      <td>877000.0</td>\n",
       "      <td>312034000</td>\n",
       "      <td>6.8</td>\n",
       "      <td>2.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>145 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Year  Marriages  Divorces  Population  Marriages_per_1000  \\\n",
       "0    1867   357000.0   10000.0    36970000                 9.7   \n",
       "1    1868   345000.0   10000.0    37885000                 9.1   \n",
       "2    1869   348000.0   11000.0    38870000                 9.0   \n",
       "3    1870   352000.0   11000.0    39905000                 8.8   \n",
       "4    1871   359000.0   12000.0    41010000                 8.8   \n",
       "..    ...        ...       ...         ...                 ...   \n",
       "140  2007  2197000.0  856000.0   301696000                 7.3   \n",
       "141  2008  2157000.0  844000.0   304543000                 7.1   \n",
       "142  2009  2080000.0  840000.0   307240000                 6.8   \n",
       "143  2010  2096000.0  872000.0   309776000                 6.8   \n",
       "144  2011  2118000.0  877000.0   312034000                 6.8   \n",
       "\n",
       "     Divorces_per_1000  \n",
       "0                  0.3  \n",
       "1                  0.3  \n",
       "2                  0.3  \n",
       "3                  0.3  \n",
       "4                  0.3  \n",
       "..                 ...  \n",
       "140                2.8  \n",
       "141                2.8  \n",
       "142                2.7  \n",
       "143                2.8  \n",
       "144                2.8  \n",
       "\n",
       "[145 rows x 6 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "data=data.interpolate(method='linear',axis=0).ffill().bfill()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877,\n",
       "       1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888,\n",
       "       1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899,\n",
       "       1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910,\n",
       "       1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921,\n",
       "       1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932,\n",
       "       1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943,\n",
       "       1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954,\n",
       "       1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965,\n",
       "       1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976,\n",
       "       1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987,\n",
       "       1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,\n",
       "       1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,\n",
       "       2010, 2011], dtype=int64)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Year.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       357000.0\n",
       "1       345000.0\n",
       "2       348000.0\n",
       "3       352000.0\n",
       "4       359000.0\n",
       "         ...    \n",
       "140    2197000.0\n",
       "141    2157000.0\n",
       "142    2080000.0\n",
       "143    2096000.0\n",
       "144    2118000.0\n",
       "Name: Marriages, Length: 145, dtype: float64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Marriages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       10000.0\n",
       "1       10000.0\n",
       "2       11000.0\n",
       "3       11000.0\n",
       "4       12000.0\n",
       "         ...   \n",
       "140    856000.0\n",
       "141    844000.0\n",
       "142    840000.0\n",
       "143    872000.0\n",
       "144    877000.0\n",
       "Name: Divorces, Length: 145, dtype: float64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.Divorces"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Year': array([1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877,\n",
       "        1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888,\n",
       "        1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899,\n",
       "        1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910,\n",
       "        1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921,\n",
       "        1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932,\n",
       "        1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943,\n",
       "        1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954,\n",
       "        1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965,\n",
       "        1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976,\n",
       "        1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987,\n",
       "        1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,\n",
       "        1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,\n",
       "        2010, 2011], dtype=int64),\n",
       " 'marriages': 0       357000.0\n",
       " 1       345000.0\n",
       " 2       348000.0\n",
       " 3       352000.0\n",
       " 4       359000.0\n",
       "          ...    \n",
       " 140    2197000.0\n",
       " 141    2157000.0\n",
       " 142    2080000.0\n",
       " 143    2096000.0\n",
       " 144    2118000.0\n",
       " Name: Marriages, Length: 145, dtype: float64,\n",
       " 'divorces': array([  10000.        ,   10000.        ,   11000.        ,\n",
       "          11000.        ,   12000.        ,   12000.        ,\n",
       "          13000.        ,   14000.        ,   14000.        ,\n",
       "          15000.        ,   16000.        ,   16000.        ,\n",
       "          17000.        ,   20000.        ,   21000.        ,\n",
       "          22000.        ,   23000.        ,   23000.        ,\n",
       "          23000.        ,   26000.        ,   28000.        ,\n",
       "          29000.        ,   32000.        ,   33000.        ,\n",
       "          36000.        ,   37000.        ,   37000.        ,\n",
       "          38000.        ,   40000.        ,   43000.        ,\n",
       "          45000.        ,   48000.        ,   51000.        ,\n",
       "          56000.        ,   61000.        ,   61000.        ,\n",
       "          65000.        ,   66000.        ,   68000.        ,\n",
       "          72000.        ,   77000.        ,   77000.        ,\n",
       "          80000.        ,   83000.        ,   89000.        ,\n",
       "          94000.        ,   91000.        ,  101000.        ,\n",
       "         104000.        ,  114000.        ,  122000.        ,\n",
       "         116000.        ,  142000.        ,  171000.        ,\n",
       "         160000.        ,  149000.        ,  165000.        ,\n",
       "         171000.        ,  175000.        ,  185000.        ,\n",
       "         196000.        ,  200000.        ,  206000.        ,\n",
       "         196000.        ,  188000.        ,  164000.        ,\n",
       "         165000.        ,  204000.        ,  218000.        ,\n",
       "         236000.        ,  249000.        ,  244000.        ,\n",
       "         251000.        ,  264000.        ,  293000.        ,\n",
       "         321000.        ,  359000.        ,  400000.        ,\n",
       "         485000.        ,  610000.        ,  483000.        ,\n",
       "         408000.        ,  397000.        ,  385000.        ,\n",
       "         381000.        ,  392000.        ,  390000.        ,\n",
       "         379000.        ,  377000.        ,  382000.        ,\n",
       "         381000.        ,  368000.        ,  395000.        ,\n",
       "         393000.        ,  414000.        ,  413000.        ,\n",
       "         428000.        ,  450000.        ,  479000.        ,\n",
       "         499000.        ,  523000.        ,  584000.        ,\n",
       "         639000.        ,  708000.        ,  773000.        ,\n",
       "         845000.        ,  915000.        ,  983931.        ,\n",
       "        1036709.        , 1090430.        , 1101445.        ,\n",
       "        1135408.        , 1193062.        , 1184175.        ,\n",
       "        1219042.        , 1206684.66666667, 1194327.33333333,\n",
       "        1181970.        , 1192530.        , 1179347.        ,\n",
       "        1165646.        , 1151787.        , 1162719.        ,\n",
       "        1175851.        , 1191591.        , 1233226.        ,\n",
       "        1197297.        , 1211893.        , 1195595.33333333,\n",
       "        1179297.66666667, 1163000.        , 1135000.        ,\n",
       "        1145245.        ,  944000.        ,  940000.        ,\n",
       "         955000.        ,  927000.        ,  879000.        ,\n",
       "         847000.        ,  872000.        ,  856000.        ,\n",
       "         844000.        ,  840000.        ,  872000.        ,\n",
       "         877000.        ])}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict(Year=data.Year.values,marriages=data.Marriages,divorces=data.Divorces.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "source=ColumnDataSource(data=dict(\n",
    "    year=data.Year.values,\n",
    "    marriages=data.Marriages.values,\n",
    "    divorces=data.Divorces.values\n",
    "))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"display: table;\"><div style=\"display: table-row;\"><div style=\"display: table-cell;\"><b title=\"bokeh.models.sources.ColumnDataSource\">ColumnDataSource</b>(</div><div style=\"display: table-cell;\">id&nbsp;=&nbsp;'1492', <span id=\"1494\" style=\"cursor: pointer;\">&hellip;)</span></div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">data&nbsp;=&nbsp;{'marriages': {'__ndarray__': 'AAAAACDKFUEAAAAAoA4VQQAAAACAPRVBAAAAAAB8FUEAAAAAYOkVQQAAAABAEhdBAAAAAECPF0EAAAAAoH8XQQAAAACg9hhBAAAAACC4GEEAAAAA4BUZQQAAAABg0RlBAAAAAMC7GkEAAAAAIKYbQQAAAAAAUhxBAAAAAICKHUEAAAAAIJQeQQAAAAAgmh1BAAAAAODxHkEAAAAA4EsgQQAAAACgTx9BAAAAALBTIEEAAAAAcC4hQQAAAAAgZSFBAAAAAAARIkEAAAAAUFciQQAAAABQVyJBAAAAAMDxIUEAAAAAwOsiQQAAAADwYCNBAAAAAHCfI0EAAAAAsL4jQQAAAADQiSRBAAAAABCjJUEAAAAA4KQmQQAAAACAridBAAAAAKD2KEEAAAAAMN8oQQAAAAAgsilBAAAAADBQK0EAAAAAUJgsQQAAAABQJypBAAAAANBfK0EAAAAAQO4sQQAAAADwJC1BAAAAAJCrLkEAAAAAkCgvQQAAAADQRy9BAAAAAADDLkEAAAAAIGswQQAAAADAdDFBAAAAAICELkEAAAAAMIwxQQAAAACQcDNBAAAAAODCMUEAAAAAsE0xQQAAAACwxDJBAAAAAOgUMkEAAAAAoCAyQQAAAAA4WzJBAAAAAGhTMkEAAAAAMAkyQQAAAABo0DJBAAAAAFgyMUEAAAAAiDAwQQAAAADg9y1BAAAAABDBMEEAAAAA8N0zQQAAAACYPzRBAAAAAKjjNEEAAAAA+CM2QQAAAAA4TzRBAAAAAGBsNUEAAAAAYFo4QQAAAAAA4TlBAAAAAOAJO0EAAAAAKBA4QQAAAADgJzZBAAAAAMicOEEAAAAAnHpBQQAAAABAZT5BAAAAADiiO0EAAAAA4Bs4QQAAAAC4bzlBAAAAAHhWOEEAAAAAuHs3QQAAAAAQlzdBAAAAAFC8NkEAAAAAeFw3QQAAAABoLzhBAAAAALApN0EAAAAA+CM2QQAAAADwyzZBAAAAADg9N0EAAAAA4J43QQAAAAAoEDhBAAAAAPA8OUEAAAAASFI6QQAAAABAdztBAAAAAOhVPEEAAAAAWGc9QQAAAAAIkj9BAAAAAHRdQEEAAAAAJa1AQQAAAIBItkBBAAAAAFVpQUEAAAAAJm1BQQAAAICUIkFBAAAAAGF6QEEAAACA5XhAQQAAAIB+o0BBAAAAgKt+QUEAAAAAd9xBQQAAAACkakJBAAAAgOKZQkEAAACAkLZCQQAAAIA+00JBAAAAgOzvQkEAAACA52BCQQAAAADXXEJBAAAAAJlXQkEAAAAAwiJCQQAAAADTTkJBAAAAAJ+0QkEAAAAApy5CQQAAAIC/OkJBAAAAAEXfQUEAAACAgEpCQVVVVVXAQUJBq6qqKgA5QkEAAAAAQDBCQQAAAADQHkFBAAAAAHj9QUEAAAAAfKlBQQAAAAD4vkFBAAAAAKh4QUEAAAAAxCBBQQAAAAAsY0FBAAAAAJQoQUEAAAAANLtAQQAAAAAEw0BBAAAAAOR0QEEAAAAAAL0/QQAAAACA+z9BAAAAALgoQEE=', 'shape': (145,), 'dtype': 'float64', 'order': 'little'}, 'divorces': {'__ndarray__': 'AAAAAACIw0AAAAAAAIjDQAAAAAAAfMVAAAAAAAB8xUAAAAAAAHDHQAAAAAAAcMdAAAAAAABkyUAAAAAAAFjLQAAAAAAAWMtAAAAAAABMzUAAAAAAAEDPQAAAAAAAQM9AAAAAAACa0EAAAAAAAIjTQAAAAAAAgtRAAAAAAAB81UAAAAAAAHbWQAAAAAAAdtZAAAAAAAB21kAAAAAAAGTZQAAAAAAAWNtAAAAAAABS3EAAAAAAAEDfQAAAAAAAHeBAAAAAAACU4UAAAAAAABHiQAAAAAAAEeJAAAAAAACO4kAAAAAAAIjjQAAAAAAA/+RAAAAAAAD55UAAAAAAAHDnQAAAAAAA5+hAAAAAAABY60AAAAAAAMntQAAAAAAAye1AAAAAAAC970AAAAAAAB3wQAAAAAAAmvBAAAAAAACU8UAAAAAAgMzyQAAAAACAzPJAAAAAAACI80AAAAAAgEP0QAAAAACAuvVAAAAAAADz9kAAAAAAgDf2QAAAAACAqPhAAAAAAABk+UAAAAAAANX7QAAAAAAAyf1AAAAAAABS/EAAAAAAgFUBQQAAAADA3wRBAAAAAACIA0EAAAAAQDACQQAAAABAJARBAAAAAMDfBEEAAAAAwFwFQQAAAABAlQZBAAAAAADtB0EAAAAAAGoIQQAAAACAJQlBAAAAAADtB0EAAAAAAPMGQQAAAAAABQRBAAAAAEAkBEEAAAAAAOcIQQAAAACAnApBAAAAAADPDEEAAAAAQGUOQQAAAAAAyQ1BAAAAAMCjDkEAAAAAAB0QQQAAAAAg4hFBAAAAAKCXE0EAAAAAYOkVQQAAAAAAahhBAAAAACCaHUEAAAAAoJ0iQQAAAADgeh1BAAAAAADnGEEAAAAAIDsYQQAAAACgfxdBAAAAACBBF0EAAAAAAO0XQQAAAADAzRdBAAAAAOAhF0EAAAAAoAIXQQAAAADAUBdBAAAAACBBF0EAAAAAAHYWQQAAAADgGxhBAAAAAKD8F0EAAAAAwEQZQQAAAAAgNRlBAAAAAIAfGkEAAAAAQHcbQQAAAABgPB1BAAAAAOB0HkEAAAAA4OsfQQAAAACA0iFBAAAAADCAI0EAAAAAQJslQQAAAAAQlydBAAAAAJDJKUEAAAAAcOwrQQAAAAD2Bi5BAAAAAEqjL0EAAAAAfqMwQQAAAACFzjBBAAAAADBTMUEAAAAAZjQyQQAAAACvETJBAAAAAOKZMkGrqqqqnGkyQVVVVVVXOTJBAAAAABIJMkEAAAAAUjIyQQAAAADT/jFBAAAAAE7JMUEAAAAAK5MxQQAAAADfvTFBAAAAACvxMUEAAAAApy4yQQAAAABK0TJBAAAAAPFEMkEAAAAA9X0yQVVVVVVLPjJBq6qqqqH+MUEAAAAA+L4xQQAAAACYUTFBAAAAAJ15MUEAAAAAAM8sQQAAAADAryxBAAAAAPAkLUEAAAAAMEosQQAAAAAw0ypBAAAAADDZKUEAAAAAgJwqQQAAAACAHypBAAAAAMDBKUEAAAAAgKIpQQAAAACAnCpBAAAAAJDDKkE=', 'shape': (145,), 'dtype': 'float64', 'order': 'little'}, 'year': [1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011]},</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">js_event_callbacks&nbsp;=&nbsp;{},</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">js_property_callbacks&nbsp;=&nbsp;{},</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">name&nbsp;=&nbsp;None,</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">selected&nbsp;=&nbsp;Selection(id='1495', ...),</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">selection_policy&nbsp;=&nbsp;UnionRenderers(id='1496', ...),</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">subscribed_events&nbsp;=&nbsp;[],</div></div><div class=\"1493\" style=\"display: none;\"><div style=\"display: table-cell;\"></div><div style=\"display: table-cell;\">tags&nbsp;=&nbsp;[])</div></div></div>\n",
       "<script>\n",
       "(function() {\n",
       "  var expanded = false;\n",
       "  var ellipsis = document.getElementById(\"1494\");\n",
       "  ellipsis.addEventListener(\"click\", function() {\n",
       "    var rows = document.getElementsByClassName(\"1493\");\n",
       "    for (var i = 0; i < rows.length; i++) {\n",
       "      var el = rows[i];\n",
       "      el.style.display = expanded ? \"none\" : \"table-row\";\n",
       "    }\n",
       "    ellipsis.innerHTML = expanded ? \"&hellip;)\" : \"&lsaquo;&lsaquo;&lsaquo;\";\n",
       "    expanded = !expanded;\n",
       "  });\n",
       "})();\n",
       "</script>\n"
      ],
      "text/plain": [
       "ColumnDataSource(id='1492', ...)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"9e1e69d6-e9cb-49ed-bfcf-981403be2d8c\" data-root-id=\"1497\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"9d0ca5fc-4e33-4a05-afbc-25f5fcccb4aa\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1506\"}],\"center\":[{\"id\":\"1509\"},{\"id\":\"1513\"}],\"left\":[{\"id\":\"1510\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1535\"},{\"id\":\"1540\"}],\"title\":{\"id\":\"1531\"},\"toolbar\":{\"id\":\"1520\"},\"x_range\":{\"id\":\"1498\"},\"x_scale\":{\"id\":\"1502\"},\"y_range\":{\"id\":\"1500\"},\"y_scale\":{\"id\":\"1504\"}},\"id\":\"1497\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"axis\":{\"id\":\"1510\"},\"dimension\":1,\"ticker\":null},\"id\":\"1513\",\"type\":\"Grid\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1518\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1496\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1495\",\"type\":\"Selection\"},{\"attributes\":{\"data\":{\"divorces\":{\"__ndarray__\":\"AAAAAACIw0AAAAAAAIjDQAAAAAAAfMVAAAAAAAB8xUAAAAAAAHDHQAAAAAAAcMdAAAAAAABkyUAAAAAAAFjLQAAAAAAAWMtAAAAAAABMzUAAAAAAAEDPQAAAAAAAQM9AAAAAAACa0EAAAAAAAIjTQAAAAAAAgtRAAAAAAAB81UAAAAAAAHbWQAAAAAAAdtZAAAAAAAB21kAAAAAAAGTZQAAAAAAAWNtAAAAAAABS3EAAAAAAAEDfQAAAAAAAHeBAAAAAAACU4UAAAAAAABHiQAAAAAAAEeJAAAAAAACO4kAAAAAAAIjjQAAAAAAA/+RAAAAAAAD55UAAAAAAAHDnQAAAAAAA5+hAAAAAAABY60AAAAAAAMntQAAAAAAAye1AAAAAAAC970AAAAAAAB3wQAAAAAAAmvBAAAAAAACU8UAAAAAAgMzyQAAAAACAzPJAAAAAAACI80AAAAAAgEP0QAAAAACAuvVAAAAAAADz9kAAAAAAgDf2QAAAAACAqPhAAAAAAABk+UAAAAAAANX7QAAAAAAAyf1AAAAAAABS/EAAAAAAgFUBQQAAAADA3wRBAAAAAACIA0EAAAAAQDACQQAAAABAJARBAAAAAMDfBEEAAAAAwFwFQQAAAABAlQZBAAAAAADtB0EAAAAAAGoIQQAAAACAJQlBAAAAAADtB0EAAAAAAPMGQQAAAAAABQRBAAAAAEAkBEEAAAAAAOcIQQAAAACAnApBAAAAAADPDEEAAAAAQGUOQQAAAAAAyQ1BAAAAAMCjDkEAAAAAAB0QQQAAAAAg4hFBAAAAAKCXE0EAAAAAYOkVQQAAAAAAahhBAAAAACCaHUEAAAAAoJ0iQQAAAADgeh1BAAAAAADnGEEAAAAAIDsYQQAAAACgfxdBAAAAACBBF0EAAAAAAO0XQQAAAADAzRdBAAAAAOAhF0EAAAAAoAIXQQAAAADAUBdBAAAAACBBF0EAAAAAAHYWQQAAAADgGxhBAAAAAKD8F0EAAAAAwEQZQQAAAAAgNRlBAAAAAIAfGkEAAAAAQHcbQQAAAABgPB1BAAAAAOB0HkEAAAAA4OsfQQAAAACA0iFBAAAAADCAI0EAAAAAQJslQQAAAAAQlydBAAAAAJDJKUEAAAAAcOwrQQAAAAD2Bi5BAAAAAEqjL0EAAAAAfqMwQQAAAACFzjBBAAAAADBTMUEAAAAAZjQyQQAAAACvETJBAAAAAOKZMkGrqqqqnGkyQVVVVVVXOTJBAAAAABIJMkEAAAAAUjIyQQAAAADT/jFBAAAAAE7JMUEAAAAAK5MxQQAAAADfvTFBAAAAACvxMUEAAAAApy4yQQAAAABK0TJBAAAAAPFEMkEAAAAA9X0yQVVVVVVLPjJBq6qqqqH+MUEAAAAA+L4xQQAAAACYUTFBAAAAAJ15MUEAAAAAAM8sQQAAAADAryxBAAAAAPAkLUEAAAAAMEosQQAAAAAw0ypBAAAAADDZKUEAAAAAgJwqQQAAAACAHypBAAAAAMDBKUEAAAAAgKIpQQAAAACAnCpBAAAAAJDDKkE=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[145]},\"marriages\":{\"__ndarray__\":\"AAAAACDKFUEAAAAAoA4VQQAAAACAPRVBAAAAAAB8FUEAAAAAYOkVQQAAAABAEhdBAAAAAECPF0EAAAAAoH8XQQAAAACg9hhBAAAAACC4GEEAAAAA4BUZQQAAAABg0RlBAAAAAMC7GkEAAAAAIKYbQQAAAAAAUhxBAAAAAICKHUEAAAAAIJQeQQAAAAAgmh1BAAAAAODxHkEAAAAA4EsgQQAAAACgTx9BAAAAALBTIEEAAAAAcC4hQQAAAAAgZSFBAAAAAAARIkEAAAAAUFciQQAAAABQVyJBAAAAAMDxIUEAAAAAwOsiQQAAAADwYCNBAAAAAHCfI0EAAAAAsL4jQQAAAADQiSRBAAAAABCjJUEAAAAA4KQmQQAAAACAridBAAAAAKD2KEEAAAAAMN8oQQAAAAAgsilBAAAAADBQK0EAAAAAUJgsQQAAAABQJypBAAAAANBfK0EAAAAAQO4sQQAAAADwJC1BAAAAAJCrLkEAAAAAkCgvQQAAAADQRy9BAAAAAADDLkEAAAAAIGswQQAAAADAdDFBAAAAAICELkEAAAAAMIwxQQAAAACQcDNBAAAAAODCMUEAAAAAsE0xQQAAAACwxDJBAAAAAOgUMkEAAAAAoCAyQQAAAAA4WzJBAAAAAGhTMkEAAAAAMAkyQQAAAABo0DJBAAAAAFgyMUEAAAAAiDAwQQAAAADg9y1BAAAAABDBMEEAAAAA8N0zQQAAAACYPzRBAAAAAKjjNEEAAAAA+CM2QQAAAAA4TzRBAAAAAGBsNUEAAAAAYFo4QQAAAAAA4TlBAAAAAOAJO0EAAAAAKBA4QQAAAADgJzZBAAAAAMicOEEAAAAAnHpBQQAAAABAZT5BAAAAADiiO0EAAAAA4Bs4QQAAAAC4bzlBAAAAAHhWOEEAAAAAuHs3QQAAAAAQlzdBAAAAAFC8NkEAAAAAeFw3QQAAAABoLzhBAAAAALApN0EAAAAA+CM2QQAAAADwyzZBAAAAADg9N0EAAAAA4J43QQAAAAAoEDhBAAAAAPA8OUEAAAAASFI6QQAAAABAdztBAAAAAOhVPEEAAAAAWGc9QQAAAAAIkj9BAAAAAHRdQEEAAAAAJa1AQQAAAIBItkBBAAAAAFVpQUEAAAAAJm1BQQAAAICUIkFBAAAAAGF6QEEAAACA5XhAQQAAAIB+o0BBAAAAgKt+QUEAAAAAd9xBQQAAAACkakJBAAAAgOKZQkEAAACAkLZCQQAAAIA+00JBAAAAgOzvQkEAAACA52BCQQAAAADXXEJBAAAAAJlXQkEAAAAAwiJCQQAAAADTTkJBAAAAAJ+0QkEAAAAApy5CQQAAAIC/OkJBAAAAAEXfQUEAAACAgEpCQVVVVVXAQUJBq6qqKgA5QkEAAAAAQDBCQQAAAADQHkFBAAAAAHj9QUEAAAAAfKlBQQAAAAD4vkFBAAAAAKh4QUEAAAAAxCBBQQAAAAAsY0FBAAAAAJQoQUEAAAAANLtAQQAAAAAEw0BBAAAAAOR0QEEAAAAAAL0/QQAAAACA+z9BAAAAALgoQEE=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[145]},\"year\":[1867,1868,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011]},\"selected\":{\"id\":\"1495\"},\"selection_policy\":{\"id\":\"1496\"}},\"id\":\"1492\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1517\",\"type\":\"SaveTool\"},{\"attributes\":{\"source\":{\"id\":\"1492\"}},\"id\":\"1541\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"144 years of marriage and divorce in the U.S.\"},\"id\":\"1531\",\"type\":\"Title\"},{\"attributes\":{\"data_source\":{\"id\":\"1492\"},\"glyph\":{\"id\":\"1538\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"divorces\",\"nonselection_glyph\":{\"id\":\"1539\"},\"selection_glyph\":null,\"view\":{\"id\":\"1541\"}},\"id\":\"1540\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"interval\":10,\"num_minor_ticks\":0},\"id\":\"1527\",\"type\":\"SingleIntervalTicker\"},{\"attributes\":{},\"id\":\"1514\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1511\",\"type\":\"BasicTicker\"},{\"attributes\":{\"format\":\"0.0a\"},\"id\":\"1529\",\"type\":\"NumeralTickFormatter\"},{\"attributes\":{},\"id\":\"1498\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"mode\":\"vline\",\"tooltips\":\"<font face=\\\"Arial\\\" size=\\\"3\\\">@$name{0.0} $name per 1,000 people in @year</font>\"},\"id\":\"1519\",\"type\":\"HoverTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":3,\"x\":{\"field\":\"year\"},\"y\":{\"field\":\"marriages\"}},\"id\":\"1534\",\"type\":\"Line\"},{\"attributes\":{\"overlay\":{\"id\":\"1518\"}},\"id\":\"1516\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1502\",\"type\":\"LinearScale\"},{\"attributes\":{\"formatter\":{\"id\":\"1579\"},\"ticker\":{\"id\":\"1527\"}},\"id\":\"1506\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#ff7f0e\",\"line_width\":3,\"x\":{\"field\":\"year\"},\"y\":{\"field\":\"divorces\"}},\"id\":\"1539\",\"type\":\"Line\"},{\"attributes\":{\"axis_label\":\"# per 1,000 people\",\"formatter\":{\"id\":\"1529\"},\"ticker\":{\"id\":\"1511\"}},\"id\":\"1510\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"1492\"}},\"id\":\"1536\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1492\"},\"glyph\":{\"id\":\"1533\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"marriages\",\"nonselection_glyph\":{\"id\":\"1534\"},\"selection_glyph\":null,\"view\":{\"id\":\"1536\"}},\"id\":\"1535\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1514\"},{\"id\":\"1515\"},{\"id\":\"1516\"},{\"id\":\"1517\"},{\"id\":\"1519\"}]},\"id\":\"1520\",\"type\":\"Toolbar\"},{\"attributes\":{\"line_color\":\"#ff7f0e\",\"line_width\":3,\"x\":{\"field\":\"year\"},\"y\":{\"field\":\"divorces\"}},\"id\":\"1538\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1579\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1515\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1504\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1500\",\"type\":\"DataRange1d\"},{\"attributes\":{\"line_color\":\"#1f77b4\",\"line_width\":3,\"x\":{\"field\":\"year\"},\"y\":{\"field\":\"marriages\"}},\"id\":\"1533\",\"type\":\"Line\"},{\"attributes\":{\"axis\":{\"id\":\"1506\"},\"ticker\":null},\"id\":\"1509\",\"type\":\"Grid\"}],\"root_ids\":[\"1497\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"9d0ca5fc-4e33-4a05-afbc-25f5fcccb4aa\",\"root_ids\":[\"1497\"],\"roots\":{\"1497\":\"9e1e69d6-e9cb-49ed-bfcf-981403be2d8c\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1497"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "TOOLS='pan,wheel_zoom,box_zoom,save'# 工具条\n",
    "p = figure(tools=TOOLS, \n",
    "           plot_width=600, \n",
    "           plot_height=400,\n",
    "           tooltips='<font face=\"Arial\" size=\"3\">@$name{0.0} $name per 1,000 people in @year</font>')\n",
    "\n",
    "# 定义画布的内容（坐标轴刻度）models\n",
    "p.hover.mode = 'vline'\n",
    "p.xaxis.ticker = SingleIntervalTicker(interval=10, num_minor_ticks=0)\n",
    "p.yaxis.formatter = NumeralTickFormatter(format='0.0a')\n",
    "p.yaxis.axis_label = '# per 1,000 people'\n",
    "p.title.text = '144 years of marriage and divorce in the U.S.'\n",
    "# 绘图\n",
    "p.line('year', 'marriages', color='#1f77b4', line_width=3, source=source, name=\"marriages\")\n",
    "p.line('year', 'divorces', color='#ff7f0e', line_width=3, source=source, name=\"divorces\")\n",
    "# 显示\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
